package com.chineseall.app.controller;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;

import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

@Component
public class InitContext implements ServletContextAware {

    private ServletContext context;

    @PostConstruct
    public void init() {
        //初始化logback
        //     LogbackHelper.getInstance().initLog();

        // 页脚服务器名 applicationScope.uriPrefix
        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.CHINA);

        String formattedDate = dateFormat.format(date);

        context.setAttribute("startDate", formattedDate);

    }

    @Override
    public void setServletContext(ServletContext servletContext) {
        this.context = servletContext;
    }

}
